# coding:utf-8

"""
tf_demo06_define_addLayer
Created on 2016/12/9 14:37
@author: GuoYufu
@group : OceanHorn
@contact: OceanHorn@163.com
"""

import tensorflow as tf

def add_layer(inputs, in_size, out_size, activation_function=None):

    weights = tf.Variable(
        initial_value=tf.random_normal(shape=[in_size, out_size])
    )
    biases = tf.Variable(
        tf.zeros([1, out_size]) + 0.1
    )
    wx_plus_b = tf.matmul(inputs, weights) + biases

    if activation_function is None:
        outputs = wx_plus_b
    else:
        outputs = activation_function(wx_plus_b)
    return outputs